import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout.vue'
import Home from '@/views/Home/Home.vue'
const Login = () => import('@/views/Login.vue')
const Category = () => import('@/views/Category/Category.vue')

const routes = [
  //配置路由：当匹配到什么路径就加载什么组件
  {
    name: 'layout',
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home,
      }, {
        path: '/category/:id',
        component: Category
      }
    ]
  },
  {
    name: 'login',
    path: '/login',
    component: Login,
  }
]

const router = createRouter({
  //Hash模式，因为没有选择H5的历史模式
  history: createWebHashHistory(),
  routes
})

export default router
